from langchain_community.chat_models import ChatZhipuAI
import os

from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent
from langchain_community.tools.tavily_search import TavilySearchResults
os.environ["ZHIPUAI_API_KEY"] = "hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3"

llm = ChatZhipuAI(temperature=0.01, model="glm-4")
os.environ["TAVILY_API_KEY"] = "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"
tools = [TavilySearchResults(max_results=2)]
prompt = hub.pull("hwchase17/react")

#Choose the LLM to use
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
agent_executor.invoke({"input": "三十而立立的是哪三样"})